package com.zr.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zr.dao.RouteDao;
import com.zr.model.TRoute;
import com.zr.service.RouteService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

//把这个类当做一个service层
@Service("routeService")
public class RouteServiceImpl implements RouteService{
	//按照配置（依据名称或者依据类型）给属性注入实例
	@Resource
	private RouteDao<TRoute> routeDao;
	@Override
	public JSONObject showRouteMsg(int page, int rows) {
		// TODO Auto-generated method stub
		//Map<String,Object> obj = new HashMap<String,Object>();
		JSONObject obj = new JSONObject();
		obj.put("total", routeDao.showRouteCount());
	    obj.put("rows", routeDao.showRouteMsg(page, rows));
		//JSONObject jso = JSONObject.fromObject(obj);
		return obj;
	}
	@Override
	public JSONArray findDpnameMsg() {
		// TODO Auto-generated method stub
		return routeDao.findDpnameMsg();
	}
	@Override
	public boolean addRouteMsg(String rname, String rstart, String rend) {
		// TODO Auto-generated method stub
		return routeDao.addRouteMsg(rname, rstart, rend);
	}
	@Override
	public void deleteRouteMsg(String[] rids) {
		// TODO Auto-generated method stub
		for (int i = 0; i < rids.length; i++) {
			routeDao.deleteRouteMsg(Integer.valueOf(rids[i]));
		}
	}
	@Override
	public void updateRouteMsg(int rid, String rname, String rstart, String rend) {
		// TODO Auto-generated method stub
		routeDao.updateRouteMsg(rid, rname, rstart, rend);
	}

}
